package com.parser.apk;

import java.util.List;

/**
 * Created by admin on 2017/12/5.
 */
public class APKCommonInfo {
    public static final String VERSION_CODE = "versionCode";
    public static final String VERSION_NAME = "versionName";
    public static final String PACKAGE = "package";
    public static final String MIN_SDK_VERSION = "minSdkVersion";
    public static final String TARGET_SDK_VERSION = "targetSdkVersion";
    public static final String PERMISSION_START_TAG = "android.permission";
    public static final String LABEL = "label";
    public static final String APPLICATION = "application";

    private String packageName;
    private String versionCode;
    private String versionName;
    private int minSdkVersion;
    private int targetSdkVersion;
    private String label;

    private List<String> permissionList;

    public String getPackageName() {
        return packageName;
    }

    public void setPackageName(String packageName) {
        this.packageName = packageName;
    }

    public String getVersionCode() {
        return versionCode;
    }

    public void setVersionCode(String versionCode) {
        this.versionCode = versionCode;
    }

    public String getVersionName() {
        return versionName;
    }

    public void setVersionName(String versionName) {
        this.versionName = versionName;
    }

    public int getMinSdkVersion() {
        return minSdkVersion;
    }

    public void setMinSdkVersion(int minSdkVersion) {
        this.minSdkVersion = minSdkVersion;
    }

    public int getTargetSdkVersion() {
        return targetSdkVersion;
    }

    public void setTargetSdkVersion(int targetSdkVersion) {
        this.targetSdkVersion = targetSdkVersion;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public List<String> getPermissionList() {
        return permissionList;
    }

    public void setPermissionList(List<String> permissionList) {
        this.permissionList = permissionList;
    }

    private String getPermissionListFormatString() {
        if (permissionList != null && permissionList.size() > 0) {
            StringBuilder stringBuilder = new StringBuilder();
            for (String permission : permissionList) {
                stringBuilder.append("\n").append(permission);
            }
            return stringBuilder.toString();
        }
        return "";
    }

    @Override
    public String toString() {
        return "packageName : " + packageName
                + "\nversionCode : " + versionCode
                + "\nversionName : " + versionName
                + "\nminSdkVersion : " + minSdkVersion
                + "\ntargetSdkVersion : " + targetSdkVersion
                + "\nlabel : " + label
                + getPermissionListFormatString();
    }
}
